close all
clear
clc


numBoot = 5000;
minObsRec = 20;

resGSW = load(['GSWresPCA_numBoot',num2str(numBoot),'_minObsRec',num2str(minObsRec),'.mat']);

% figure;
% hold on
% plot(resGSW.matSelectUsed/12,resGSW.meanBetaRegime_change,'-k')
% plot(resGSW.matSelectUsed/12,resGSW.XhrRegime_dbeta_draws_prctile(:,1),':k')
% plot(resGSW.matSelectUsed/12,resGSW.XhrRegime_dbeta_draws_prctile(:,2),':k')
% plot(resGSW.matSelectUsed/12,resGSW.resData.coef_dbeta,'-r');
% title('Regime-switching: Change in Beta')
% axis tight
% 
% figure;
% hold on
% plot(resGSW.matSelectUsed/12,resGSW.meanBetaRegime_change./resGSW.meanSEXhrRegime_dbeta_draws,'-k') 
% plot(resGSW.matSelectUsed/12,resGSW.tstatBetaRegime_change(:,1),':k')
% plot(resGSW.matSelectUsed/12,resGSW.tstatBetaRegime_change(:,2),':k')
% plot(resGSW.matSelectUsed/12,resGSW.resData.tstat_dbeta,'-r')
% title('Regime-switching: change in Beta')


%% Plotting some results

selectMat = (24:3:120);

plotHeight = 14+6;
plotWidth = 18+7+5;
subPlotsX = 1+1;
subPlotsY = 2-1;   
leftEdge = 1.2;
rightEdge = 0.4;   
topEdge = 1.5;
bottomEdge = 1.5;
spaceX = 1.5;
spaceY = 2.75;
fontSize = 16; 

subPos = subPlotPos(plotWidth,plotHeight,leftEdge,rightEdge,bottomEdge,topEdge,subPlotsX,subPlotsY,spaceX,spaceY);

%setting the Matlab figure
f = figure('visible','on','name','Data');
clf(f);
set(gcf, 'PaperUnits', 'centimeters');
set(gcf, 'PaperSize', [plotWidth plotHeight]);
set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperPosition', [0 0 plotWidth plotHeight]);
 
ax(1) = axes('position',subPos{1,1},'XGrid','off','XMinorGrid','off','FontSize',fontSize,'Box','on','Layer','top');

p = plot(resGSW.matSelectUsed(selectMat)'/12, ...
[resGSW.resData.tstat_dalfa(selectMat)' ...
 resGSW.tstatAlfaRegime_change(selectMat,2) ... 
 resGSW.tstatAlfaRegime_change(selectMat,1)]);

line([resGSW.matSelectUsed(selectMat(1))/12 ; resGSW.matSelectUsed(selectMat(end))/12],[0 ; 0],'Color','k','LineWidth',0.1,'LineStyle','-');
hL = legend(p([1 2]),{'Empirical t-statistics','Bootstrapped 95% confidence interval'},'Orientation','horizontal','box','off');

set(hL,'Position', [0.30 0.93+0.04 0.42 0.04],'Units', 'normalized','FontSize',12+4); 
set(ax(1),'FontSize',16);
%axis tight

title('For $\alpha_k^{\Delta}$','interpreter','Latex','FontSize',12+4)

set(p(1),'Color',[0 0 0],'LineWidth',2.25);
set(p([2 3]),'Color',[0 0 0],'LineWidth',1);
set(p([2 3]),'LineStyle',':');
xlabel('Maturity in years','interpreter','Latex','FontSize',12+4)

ax(2) = axes('position',subPos{1,2},'XGrid','off','XMinorGrid','off','FontSize',fontSize,'Box','on','Layer','top');

p2 = plot(resGSW.matSelectUsed(selectMat)'/12, ...
[resGSW.resData.tstat_dbeta(selectMat)' ...
 resGSW.tstatBetaRegime_change(selectMat,2) ... 
 resGSW.tstatBetaRegime_change(selectMat,1)]);

title('For $\beta_k^{\Delta}$','interpreter','Latex','FontSize',12+4)

set(p2(1),'Color',[0 0 0],'LineWidth',2.25);
set(p2([2 3]),'Color',[0 0 0],'LineWidth',1);
set(p2([2 3]),'LineStyle',':');
line([resGSW.matSelectUsed(selectMat(1))/12 ; resGSW.matSelectUsed(selectMat(end))/12],[0 ; 0],'Color','k','LineWidth',0.1,'LineStyle','-');
set(ax(2),'FontSize',16);
%axis tight
xlabel('Maturity in years','interpreter','Latex','FontSize',12+4)


print(gcf, '-depsc2','-loose',['BauerAndHamilton','.eps']);

